import { Service } from "cl-admin";
import BaseService from "@/service/base";
@Service("ad")
class Ad extends BaseService {
	list(params) {
		return this.$get("/lists", { params });
	}
	// 落地页列表
	page({ size, ...args }) {
		let params = {
			...args,
			page_size: size
		};
		return this.$get("/lists", { params }).then(res => {
			return {
				list: res.lists,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	// 落地页  新增落地页
	add(params) {
		return this.$post("/add", params);
	}
	// 编辑
	update(params) {
		return this.$post("/edit", params);
	}

	// 删除
	remove(params) {
		return this.$post("/del", params);
	}

	//获取微信池列表
	getWxPool(params) {
		return this.$get("/wxPool", { params });
	}
	//给账号设置微信池
	setWPool(params) {
		return this.$post("/setPool", params);
	}



	// 落地页（城市）不分页 -- 列表
	citylists(params) {
		return this.$get("/citylists", { params });
	}
	cityPage({ size, ...args }) {
		let params = {
			...args,
			page_size: size
		};
		return this.$get("/citylists", { params }).then(res => {
			return {
				list: res.lists,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}
	// 推广 => 行为代码
	// 增
	behaviorAdd(params) {
		return this.$post("/behavior/add", params);
	}
	// 查
	behaviorList({ size, ...args }) {
		let params = {
			...args,
			page_size: size
		};
		return this.$get("/behavior/lists", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
	}

	// 删
	behaviorDel(params) {
		return this.$post("/behavior/del", params);
	}
	// 改
	behaviorEdit(params) {
		return this.$post("/behavior/edit", params);
	}

	// 推广 => 落地页报表 => 配置白晚班
	// 增
	classesAdd(params) {
		return this.$post("/classes/add", params);
	}
	// 查
	classesList(params) {
		return this.$get("/classes/lists", { params });
	}

	// 删
	classesDel(params) {
		return this.$post("/classes/del", params);
	}
	// 改
	classesEdit(params) {
		return this.$post("/classes/edit", params);
	}

	// 推广 =>
	// 增
	templateAdd(params) {
		return this.$post("/template/add", params);
	}
	// 查
	templateList({ size, ...args }) {
		let params = {
			...args,
			size
		};
		return this.$get("/template/lists", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					size,
					total: res.total
				},
				total: res.total
			};
		});
	}
    // 新的查询接口
	NewtemplateList(params) {
		return this.$get("/template/lists", {params});
	}
	templateSelfLists(params) {
		return this.$get("/template/selfLists", { params });
	}
	// 删
	templateDel(params) {
		return this.$post("/template/del", params);
	}
	// 改
	templateEdit(params) {
		return this.$post("/template/edit", params);
	}
	// 详情
	templateInfo(params) {
		return this.$get("/template/view", { params });
	}
	// 获取行为代码
	templateBehavior(params) {
		return this.$get("/template/getBehavior", { params });
	}
	// 推广 => 落地页列表 => 列表链接
	// 增
	templateBindAdd(params) {
		return this.$post("/templatebind/add", params);
	}
	// 查
	templateBindView(params) {
		return this.$get("/templatebind/view", { params });
	}
	// 微信变更日记
	wechatlogs(params) {
		return this.$get("/wechatlog/lists", { params });
	}
	// 落地页报表按微信汇总
	adreport({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/adreport", { params });
	}
	//渠道id
	channelList({ date = [], bra_id = [], ...args }) {
		let params = {
			...args,
			bra_id: bra_id.join()

		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/adchannel", { params });
	}
	// 落地页列表
	adplatform(params) {
		return this.$get("/adplatform", { params });
	}
	// 落地页报表日志
	advist({ date = [], ...args }) {
		let params = {
			...args
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/advist", { params }).then(res => res?.data ?? []);
	}
	// 部门推广列表
	setList(params) {
		return this.$get("/set/lists", { params });
	}
	// 添加部门推广
	setAdd(params) {
		return this.$post("/set/add", params);
	}

	// 编辑部门推广
	setEdit(params) {
		return this.$post("/set/edit", params);
	}
	// 删除部门推广
	setDel(params) {
		return this.$post("/set/del", params);
	}
	/**
	 * 配置白晚班
	 */
	//查
	classesList(params) {
		return this.$get("/classes/lists", { params });
	}
	// 增
	classesAdd(params) {
		return this.$post("/classes/add", params);
	}
	// 改
	classesEdit(params) {
		return this.$post("/classes/edit", params);
	}
	// 删
	classesDel(params) {
		return this.$post("/classes/del", params);
	}
	/**
	 * 配置落地页
	 */
	//查
	manageList(params) {
		return this.$get("/manage/lists", { params });
	}
	// 增
	manageAdd(params) {
		return this.$post("/manage/add", params);
	}
	// 改
	manageEdit(params) {
		return this.$post("/manage/edit", params);
	}
	// 删
	manageDel(params) {
		return this.$post("/manage/del", params);
	}
	/**
	 * 配置客服
	 */
	// 移除客服
	cusDel(params) {
		return this.$post("/customer/del", params);
	}
	cusList({ size, dept_ids, ...args }) {
		let params = {
			...args,
			pagesize: size,
			dept_id: dept_ids.join()
		};
		return this.$get("/customer/lists", { params });
	}
	// 配置客服落地页月度数据
	cusListMonthData({ size, dept_ids, date = [], ...args }) {
		let params = {
			...args,
			pagesize: size,
			size: size,
			dept_id: dept_ids.join()
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get('/customer/monthData', { params })
	}

	onsaleCusList(params) {
		return this.$get("/onsalecustomer/lists", { params });
	}

	// 提交
	cusSet(params) {
		return this.$post("/customer/set", params);
	}
	// 提交
	onsaleCusSet(params) {
		return this.$post("/onsalecustomer/set", params);
	}
	// 行为配置
	cusCopy(params) {
		return this.$post("/customer/copy", params, {
			data: params
			// headers: {
			// 	"Content-Type": "application/json"
			// }
		});
	}
	// 行为配置
	onsaleCusCopy(params) {
		return this.$post("/onsalecustomer/copy", params);
	}
	// 售中移除客服
	onsaleCusDel(params) {
		return this.$post("/onsalecustomer/del", params);
	}
	// 配置客服日记
	cusLogList({ date = [], ...args }) {
		let params = {
			...args
		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/customerlog/lists", { params });
	}
	// 售中配置客服日记
	onsaleCusLog(params) {
		return this.$get("/onsalecustomerlog/lists", { params });
	}

	//获取客服参与部门
	getCusDept(params) {
		return this.$get("/customer/adBizDept", { params });
	}
	// page({ size, ...args }) {
	// 	let params = {
	// 		...args,
	// 		page_size: size
	// 	};
	// 	return this.$get("/lists", { params }).then(res => {
	// 		return {
	// 			list: res.lists,
	// 			pagination: {
	// 				...params,
	// 				size,
	// 				total: res.total
	// 			}
	// 		};
	// 	});
	// }
	// 微信列表
	wxlist(params) {
		// return this.$get("/wxlist", { params });
		return this.$get("/wxlist", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					total: res.total
				}
			};
		});
	}
	/**推广部门报表 */
	deptreport({ date = [], dept_ids, bra_id = [], ...args }) {
		// console.log(dept_ids);
		let params = {
			...args,
			dept_id: dept_ids.join(),
			bra_id: bra_id.join()

		};
		if (date.length) {
			params.begin_time = date[0];
			params.end_time = date[1];
		}
		return this.$get("/deptreport", { params });
	}

	// h5链接转小程序链接
	getMiniLink(params) {
		return this.$post('/getMiniLink', params)
	}

	// 返回落地页渠道绑定信息
	bindRelatedList(params) {
		return this.$get('/bindRelated/lists', { params })
	}

	// 获取推广小程序
	adMini({ size, bra_id, ...args }) {
		let params = {
			...args,
			page_size: size
		};
		if (bra_id) {
			params.bra_id = Array.isArray(bra_id) ? bra_id.join(',') : bra_id
		}
		return this.$get("/adMini", { params }).then(res => {
			return {
				list: res?.data ?? res,
				pagination: {
					...params,
					size,
					total: res.total
				}
			};
		});
		// return this.$get('/adMini', { params })
	}

	// 设置推广小程序账号
	setAdMini(params) {
		return this.$post('/setAdMini', params)
	}

	// 修改推广小程序账号
	editAdMini(params) {
		return this.$post('/editAdMini', params)
	}

	// 删除推广小程序账号
	delAdMini(params) {
		return this.$post('/delAdMini', params)
	}

	switchCustomer({ dept_ids = [], date = [], ...args }) {
		let params = {
			...args,
			dept_id: dept_ids?.join?.()
		}
		// if (date.length) {
		// 	params.begin_time = date[0];
		// 	params.end_time = date[1];
		// }
		return this.$get('/switch/customer', { params })
	}

	switchOn(params) {
		return this.$post('/switch/on', params)
	}

	switchOff(params) {
		return this.$post('/switch/off', params)
	}

	setWechatCatch(params) {
		return this.$post('/switch/setWechatCatch', params)
	}

	setPoolMini(params) {
		return this.$post('/setPoolMini', params)
	}

	selfLists () {
		return this.$get('/selfLists')
	}
}
export default Ad;
